package com.ruoyi.performance.service.impl;

import com.ruoyi.common.core.text.Convert;
import com.ruoyi.performance.domain.PerfGroup2User;
import com.ruoyi.performance.mapper.PerfGroup2UserMapper;
import com.ruoyi.performance.service.PerfGroup2UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Service
public class PerfGroup2UserServiceImpl implements PerfGroup2UserService {
    @Autowired
    PerfGroup2UserMapper perfGroup2UserMapper;

    @Override
    public List<PerfGroup2User> selectPerfGroup2UserById(Long id){
        return perfGroup2UserMapper.selectPerfGroup2UserById(id);
    }

    @Override
    public List<PerfGroup2User> selectPerfGroup2UserByCompanycode(String Companycode){
        return perfGroup2UserMapper.selectPerfGroup2UserByCompanycode(Companycode);
    }

    @Override
    public List<PerfGroup2User> selectPerfGroup2UserList(PerfGroup2User perfGroup2User){
        return perfGroup2UserMapper.selectPerfGroup2UserList(perfGroup2User);
    }

    @Override
    public List<PerfGroup2User> selectPerfGroup2UserByGroupcode(String groupcode){
        return perfGroup2UserMapper.selectPerfGroup2UserByGroupcode(groupcode);
    }

    @Override
    public List<PerfGroup2User> selectPerfGroup2UserByUsercode(String usercode){
        return perfGroup2UserMapper.selectPerfGroup2UserByUsercode(usercode);
    }

    @Override
    public int insertPerfGroup2User(PerfGroup2User perfGroup2User){
        String date = new SimpleDateFormat("yyyy-mm-dd").format(new Date());
        String time = new SimpleDateFormat("hh-mm-ss").format(System.currentTimeMillis());
        perfGroup2User.setCreatedate(date);
        perfGroup2User.setCreatetime(time);
        return perfGroup2UserMapper.insertPerfGroup2User(perfGroup2User);
    }

    @Override
    public int updatePerfGroup2User(PerfGroup2User perfGroup2User){
        String date = new SimpleDateFormat("yyyy-mm-dd").format(new Date());
        String time = new SimpleDateFormat("hh-mm-ss").format(System.currentTimeMillis());
        perfGroup2User.setCreatedate(date);
        perfGroup2User.setCreatetime(time);
        return perfGroup2UserMapper.updatePerfGroup2User(perfGroup2User);
    }

//    @Override
//    public int deletePerfGroup2UserById(PerfGroup2User perfGroup2User){
//        String date = new SimpleDateFormat("yyyy-mm-dd").format(new Date());
//        String time = new SimpleDateFormat("hh-mm-ss").format(System.currentTimeMillis());
//        perfGroup2User.setCreatetime(time);
//        perfGroup2User.setCreatedate(date);
//        return perfGroup2UserMapper.deletePerfGroup2User(perfGroup2User);
//    }

    @Override
    public int deletePerfGroup2UserById(String id){
        return perfGroup2UserMapper.deletePerfGroup2UserById(Convert.toStrArray(id));
    }

    @Override
    public int deletePerfGroup2UserByGroupcode(String groupcode){
        return perfGroup2UserMapper.deletePerfGroup2UserByGroupcode(groupcode);
    }

//    @Override
//    public int deletePerflevelByCode(String leveltemplatecode) {
//        return perflevelMapper.deletePerflevelByCode(leveltemplatecode);
//    }
}
